
"""
    debug: 输出信息到终端 以及 mylog.txt 文件中
"""
LOGFILE = "mylog.txt"
DEBUG = True
fobj = None

def init():
    global fobj

    try: 
        fobj = open(LOGFILE, "w")
    except:
        fobj = None
        pass

def log(s):
    try:
        if fobj != None:
            fobj.write(s)
    except :
        pass

def err(s):
    s = "[err]:" + s 
    print(s)
    log(s + "\n")

def prt(s):
    print(s)
    log("[log]" + s + "\n")


def myquit():
    try:
        if fobj != None:
            fobj.close()
    except :
        pass

if __name__ == "__main__":
    init()
    prt("test")
    err("test")
    myquit()